/**
 * 
 */
package net.da.tools;

import java.util.ArrayList;
import java.util.List;

public class ClassDescriptor {
	
	public static final int HIGHEST_LEVEL = 5;
	
	public static final int LOWEST_LEVEL = 0;

	private static final String EMPTY_STRING = "";

	private static final String PACKAGE_SEPARATOR = ".";

	private String packageName;

	private String shortName;

	private List<FieldDescriptor> fields;

	private List<MethodDescriptor> methods;

	private boolean interfaceType;

	private String accessQuilifier;

	private boolean abstractClass;

	private List<ClassDescriptor> interfaces;

	private ClassDescriptor superType;
	
	private int descriptionLevel;
	

	public ClassDescriptor() {

		packageName = EMPTY_STRING;
		shortName = EMPTY_STRING;
		fields = new ArrayList<FieldDescriptor>();
		methods = new ArrayList<MethodDescriptor>();
		interfaceType = false;
		accessQuilifier = EMPTY_STRING;
		abstractClass = false;
		interfaces = new ArrayList<ClassDescriptor>();
		superType = null;
		descriptionLevel = LOWEST_LEVEL;
	}

	public List<FieldDescriptor> getFields() {
		return fields;
	}

	public void addField(FieldDescriptor field) {
		fields.add(field);
	}

	public String getFullName() {
		return getPackageName() + PACKAGE_SEPARATOR + getShortName();
	}

	public boolean isInterfaceType() {
		return interfaceType;
	}

	public void setInterfaceType(boolean interfaceType) {
		this.interfaceType = interfaceType;
	}

	public List<MethodDescriptor> getMethods() {		
		return methods;
	}

	public void addMethod(MethodDescriptor method) {		
		methods.add(method);
	}

	public String getPackageName() {
		return packageName;
	}

	public void setPackageName(String packageName) {
		this.packageName = packageName;
	}

	public String getShortName() {
		return shortName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

	public boolean isAbstractClass() {
		return abstractClass;
	}

	public void setAbstractClass(boolean abstractClass) {
		this.abstractClass = abstractClass;
	}

	public String getAccessQuilifier() {
		return accessQuilifier;
	}

	public void setAccessQuilifier(String accessQuilifier) {
		this.accessQuilifier = accessQuilifier;
	}

	public boolean isHasFields() {
		return !fields.isEmpty();
	}	

	public boolean isHasInterfaces() {
		return !interfaces.isEmpty();
	}

	public boolean isHasSuperType() {
		return superType != null;
	}

	public List<ClassDescriptor> getInterfaces() {
		return interfaces;
	}

	public void addInterface(ClassDescriptor interfaze) {
		interfaces.add(interfaze);
	}

	public ClassDescriptor getSuperType() {
		return superType;
	}

	public void setSuperType(ClassDescriptor superType) {
		this.superType = superType;
	}

	public boolean isHasMethods() {
		return !methods.isEmpty();
	}

	public int getDescriptionLevel() {
		return descriptionLevel;
	}

	public void setDescriptionLevel(int descriptionLevel) {
		this.descriptionLevel = descriptionLevel;
	}

	@Override
	public boolean equals(Object obj) {

		if (super.equals(obj)) {
			return true;
		}
		
		ClassDescriptor cd0 = this;
		ClassDescriptor cd1 = (ClassDescriptor) obj;
		String name0 = cd0.getFullName();
		String name1 = cd1.getFullName();
		
		
		return name0.equals(name1);
	}

	@Override
	public int hashCode() {
		// TODO:ALB
		return 0;
	}

	@Override
	public String toString() {		
		return getFullName();
	}
	
	
	
	

}